<%@ page language="java" contentType="text/html; charset=UTF-8" import="java.sql.*" errorPage=""%>
<%@ page import="java.util.*,java.text.*" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .title {
        margin-top: 30px;
        text-align: center;
        font-size: 40px;
    }
    table {
        margin-top: 20px;
        font-size: 25px;
    }
    .answer {
        margin-left: 400px;
        font-size: 25px;
        color: blue;
    }
    .but {
        margin-top: 20px;
        text-align: center;
    }
</style>
<body>
	<jsp:useBean id="LogBean" scope="session" class="Bean.dbConn"/>
<%

		java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
		java.util.Date currentTime = new java.util.Date();
		String str_date1 = formatter.format(currentTime); 
		
		int low = 0;
		ResultSet rs = null;
		ResultSet rb = null;
		String testpe = (String)session.getAttribute("testpe");
		Integer num = (Integer)session.getAttribute("num");
		String myid = (String)session.getAttribute("userid");
		
		DecimalFormat df1 = new DecimalFormat( "#");
		double avg1 = num.doubleValue()*1.25;
		
		if(avg1 >= 53 && avg1 <= 62) {
			low = 53;
		}
		if(avg1 >= 63 && avg1 <= 72) {
			low = 63;
		}
		if(avg1 >= 73 && avg1 <= 1000) {
			low = 73;
		}
		rb = LogBean.executeQuery("SELECT * FROM sds_report where low =" + "'"+ low +"'");
		rb.next();
		
		String dicri = rb.getString("decri");
		int sum = LogBean.executeUpdate("INSERT INTO times(myid,ti,testpe,num,avg1,dic) VALUES (" + 
	"'" + myid + "'" + "," +
	"'" + str_date1 + "'" + "," +
	"'" + testpe + "'" + "," +
	"'" + num + "'" + "," +
	"'" + df1.format(avg1) + "'" + "," +
	"'" + dicri + "'" + ")");
		
		rs = LogBean.executeQuery("SELECT * FROM user where id =" + "'"+ myid +"'");
		rs.next();
		
%>
    <div class="title">测试结果报告</div>
    <table border="0" align="center">
        <tr>
            <td>学号:</td>
            <td><%=rs.getString("number")%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
            <td>姓名:</td>
            <td><%=rs.getString("name")%></td>
        </tr>
        <tr>
            <td>班级:</td>
            <td><%=rs.getString("class")%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
            <td>性别:</td>
            <td><%=rs.getString("sex")%></td>
        </tr>
        <tr>
            <td>年龄:</td>
            <td><%=rs.getString("bril")%>岁&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
        </tr>
        <tr>
            <td>测试量表:</td>
            <td><%=testpe%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
            <td>测试时间:</td>
            <td><%=str_date1%></td>
        </tr>
        <tr>
            <td>粗分:</td>
            <td><%=num%>分&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
            <td>标准分:</td>
            <td><%=df1.format(avg1)%>分</td>
        </tr>
        <tr>
            <td>结果分析:</td>
        </tr>
    </table>
    <div class="answer">
        <%=rb.getString("decri")%> 
    </div>
    <div class="but">
        <a href="dotest.jsp" target="_blank">
            <button>返回测试首页</button>
        </a>
    </div>
    
</body>
</html>